﻿using Libs;
using WriteForFighting.Game.Asset;

namespace WriteForFighting.Game.Entity.Effect
{
    class EntityEffectExplosion : EntityEffectBase
    {
        private int[] graphHandles;
        private int animeFlame;
        private bool isSmall;

        public EntityEffectExplosion(double par1X, double par2Y, bool par3IsSmall)
            : base(par1X, par2Y)
        {
            isSmall = par3IsSmall;
            if (isSmall)
            {
                graphHandles = Drawable.EffectSmallExplosion;
            }
            else
            {
                graphHandles = Drawable.EffectExplosion;
            }
        }

        protected override void OnUpdate(int par1GameTickCount, EntityManager par2PlayersManager,
            EntityManager par3BulletsManager, EntityManager par4EffectsManager)
        {
            if (Age == 0)
            {
                if (!isSmall)
                {
                    DX.PlaySoundMem(Sound.Explosion, DX.DX_PLAYTYPE_BACK);
                }
            }
        }

        protected override void OnDraw(int par1GameTickCount)
        {
            if ((Age % 5) == 0)
            {
                animeFlame++;
            }

            if (6 < animeFlame)
            {
                IsDeath = true;
                return;
            }

            DX.DrawGraph((int)X - 30, (int)Y - 30, graphHandles[animeFlame], DX.TRUE);
        }
    }
}
